package com.suixun.controller.information;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.authority.controller.BaseManager;
import com.suixun.entity.ZxTag;
import com.suixun.service.information.ZxTagService;
import com.suixun.service.redis.RedisService;

@Controller
@RequestMapping(value = "/tag")
public class TagController extends BaseManager {

    private static final String TAG_LIST = "TAG_LIST";

    @Resource
    private ZxTagService zxTagService;
    @Resource
    private RedisService redisService;

    @RequestMapping(value = "/listTag")
    @ResponseBody
    public Object listTag() {

        List<ZxTag> listTag = (List<ZxTag>) redisService.get(TAG_LIST);
        if (CollectionUtils.isNotEmpty(listTag)) {
        	return success(listTag);
        } else {
        	listTag = zxTagService.listTag(); 
            redisService.put(TAG_LIST, listTag);
            return success(listTag);
        }

    }
    
    @RequestMapping(value = "/listArticleTag")
    @ResponseBody
    public Object listArticleTag(Integer articleId){
    	
    	return success(zxTagService.listArticleTag(articleId));
    }
}
